module.exports = class extends think.Service {
    constructor(data) {
        let that = this;
        super();
        that.data = data;
        that.handleData = {};
        that.nowTime = new Date().getTime();
        let handleData = {
            title: that.data.title,
            url: that.data.url,
            add_time: that.nowTime
        };
    }
    handleData() {

    }
    async addData() {
        let that = this;
        let detailIsExist = 0;
        if (!think.isEmpty(that.handleData.self_id)) {
            detailIsExist = await that.model('t_record_detail', '').where({ self_id: that.handleData.self_id }).count();
        }
        let uuid = think.uuid().replaceAll('-', '');
        if (!detailIsExist) {
            await that.model('t_record', '').add({ uuid, title: that.data.title, status: 0, status_str: 'NO_HANDLE', add_time: that.nowTime });
            await that.model('t_record_detail', '').add(that.handleData);
        } else {
            await that.model('t_record_detail', '').where({ self_id: that.handleData.self_id }).update({ title: that.handleData.title, url: that.handleData.url, status: that.handleData.status });
        }
    }
};
